package com.lsa.iview.chap1;

import static org.junit.Assert.assertTrue;

import org.junit.Test;

import com.lsa.helpers.Utils;

public class ArrayQuestionsTest {

	@Test
	public void test() {
		int[][] matrix = new int[][] {
				{1,2,3},
				{1,0,3},
				{4,5,6}
				};
		int[][] expectedMatrix = new int[][] {
				{1,0,3},
				{0,0,0},
				{4,0,6}
				};
		
		ArrayQuestions.setRowColToZeroIfZero(matrix);
		assertTrue(Utils.compareArrays(matrix, expectedMatrix));
		
		matrix = new int[][] {
				{0,2,3},
				{1,4,3},
				{4,5,6}
				};
		
		expectedMatrix = new int[][] {
				{0,0,0},
				{0,4,3},
				{0,5,6}
				};
		
		ArrayQuestions.setRowColToZeroIfZero(matrix);
		assertTrue(Utils.compareArrays(matrix, expectedMatrix));
		
		matrix = new int[][] {
				{1,2,3},
				{1,4,3},
				{4,5,6}
				};
		
		expectedMatrix = new int[][] {
				{1,2,3},
				{1,4,3},
				{4,5,6}
				};
		
		ArrayQuestions.setRowColToZeroIfZero(matrix);
		assertTrue(Utils.compareArrays(matrix, expectedMatrix));
		
		matrix = new int[][] {
				{0,0,0},
				{0,0,0},
				{0,0,0}
				};
		
		expectedMatrix = new int[][] {
				{0,0,0},
				{0,0,0},
				{0,0,0}
				};
		
		ArrayQuestions.setRowColToZeroIfZero(matrix);
		assertTrue(Utils.compareArrays(matrix, expectedMatrix));
		
		matrix = new int[][] {
				{0, 12,13,14},
				{21,22,23,24},
				{31,32,33,34},
				{41,42,43,0}};
		
		expectedMatrix = new int[][] {
				{0, 0, 0,  0},
				{0, 22,23, 0},
				{0, 32,33, 0},
				{0, 0, 0,  0}};
		
		ArrayQuestions.setRowColToZeroIfZero(matrix);
		assertTrue(Utils.compareArrays(matrix, expectedMatrix));
	}
}
